package com.sfdk.pools
{
    import flash.media.Sound;
    import flash.utils.Dictionary;

    public class MusicPool
    {
        private static var _instance:MusicPool;

        private var _pool:Dictionary;
        private var _totalSize:int;

        public function MusicPool() {
            _pool = new Dictionary();
            _totalSize = 0;
            _instance = this;
        }

        public static function get instance():MusicPool {
            return _instance;
        }

        public static function getFromPool(name:String):Sound {
            return _instance.getFromPool(name);
        }

        public function addToPool(sound:Sound, name:String):int {
            if (_pool[name] != null)
                return -1;

            _pool[name] = sound;
            return 1;
        }

        public function removeFromPool(name:String):void {
            _pool[name] = null;
        }

        public function getFromPool(name:String):Sound {
            var sound:Sound = _pool[name] as Sound;
            return sound;
        }

        public function isInPool(name:String):Boolean {
            return (_pool[name] != null);
        }
    }
}